<template>
  <div class='main'>
   child-b.vue  组件
 
      
    <h1>  {{count}}</h1>

<!-- 获取modules 里面定义的数据 -->
       <h1>{{$store.state.user.token}}</h1>
        <!-- <h1>{{$store.state.setting.name}}</h1> -->
        <!-- <div> 方式三: {{name}}</div> -->

        <!--  -->

          <h1> 方式二: {{user.token}}</h1>
          <!-- <h1> 方式三: {{token}}</h1> -->

<!-- 
        <ul>
          <li v-for='item in $store.getters.filterList' :key='item'>
                {{item}}   
          </li>
        </ul> -->
 <hr>
          <!-- <ul>
          <li v-for='item in filterList' :key='item'>
                {{item}}   
          </li>
        </ul> -->


   <button  @click="changeToken">点击改变 token</button>

   </div>
</template>

<script>

import  {mapActions, mapGetters, mapState} from 'vuex'
export default {
  name: '',
  data () {
    return {

    }
  },
  watch: {

  },
  props: {
  },
  components: {

  },
  computed: {
  ...mapState(['count','user']),
  // ...mapGetters(['filterList','token','name']),

  },
  mounted() {
    console.log(this.$store);
    setTimeout(()=>{
      this.asyncChangeUserToken()
    },2000)

  },
  methods: {
    ...mapActions(['asyncChangeUserToken']),
    changeToken() {
      // 方式一 
      this.$store.commit('changeUserToken')
    }

  },
  filters: {

  }
}
</script>
